<div class="content_filtro">
    <h2><?php echo $this->titulo;?></h2>
    <div class="content-btn">
        <span>Nova Dica</span><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit')); ?>">+</a>
    </div>
</div>

<div class="content-table">
    <table id="tlist">
        <thead>
            <tr>
                <th>Dica</th>
                <th>Categoria</th>
                <th>Segmentos</th>
                <th>Status</th>
                <th>Ordem</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
                //$cts = $row->findDependentRowSet("Sistema_Model_DbTable_Catsegmento");   
                $segmentos = '';
                if(strlen($row['CTS_ID']) > 0){ 
                    $query = 'SELECT SQL_CACHE CTS_NOM FROM CATSEGMENTO WHERE CTS_ID in('.$row['CTS_ID'].')';
                    $cts = $this->db->fetchAll($query);
                    foreach ($cts as $ct) $segmentos .= $ct['CTS_NOM'].', '; 
                    if(strlen($segmentos) > 0) $segmentos = substr($segmentos,0,strlen($segmentos) - 2); 
                }
                //$obj = new Sistema_Model_DbTable_Categoriadicas();
                //$cat = $obj->fetchRow('CTD_ID = '.$row['CTD_ID']);
            ?>
                <tr>  
                    <td align="left"><?php echo $row['DIC_NOM']; ?></td>
                    <td align="left"><?php echo $row['CTD_NOM']; ?></td>
                    <td><?php echo $segmentos;//$cts['CTS_NOM']; ?></td>
                    <td><?php echo tools::returnStatus($row['DIC_STA']); ?></td>
                    <td><?php echo $row['DIC_ORD']; ?></td>
                    <td class="bc">
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['DIC_ID'])); ?>">Editar</a><?php }?>
                        <?php if($this->per_del && $row['DIC_STA'] == 0){?><a class="btn-pdr" href="javascript:void(0);" onclick="list_delete('<?php echo $this->controller; ?>', <?php echo $row['DIC_ID'] ?>, $(this));">Deletar</a><?php }?>
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>